﻿using AFanDa.BLL.BLLService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace AFanDa.Admin.Controllers
{
    /// <summary>
    /// 用户 业务 控制器
    /// </summary>
    public class AdminController : Controller
    {

        AdminService _adminService = null;

        /// <summary>
        /// 
        /// </summary>
        public AdminController()
        {
            _adminService = new AdminService();

        }


        // GET: Admin
        /// <summary>
        /// 用户信息页面 （陈亚文负责）
        /// </summary>
        /// <returns></returns>
        public ActionResult AdminInfo()
        {
            return View();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="keys"></param>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        [HttpGet]
        public ActionResult GetAdmins(string keys = "", int page = 1, int limit = 10, int status = -1)
        {
            keys = keys ?? "";
            var result = _adminService.GetAdmins(new Dto.Request.AdminRequestDto
            {
                key = keys,
                page = page,
                limit = limit,
                status = status
            });

            return Json(result, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 修改用户信息页面 （陈亚文负责）
        /// </summary>
        /// <returns></returns>
        public ActionResult UpdateAdminHtml()
        {
            return View();
        }


        /// <summary>
        /// 用户详情 页面 （陈亚文负责）
        /// </summary>
        /// <returns></returns>
        public ActionResult AdminDetialsHtml()
        {
            return View();
        }

        /// <summary>
        /// 添加用户页面
        /// </summary>
        /// <returns></returns>
        public ActionResult AddAdminHtml()
        {
            return View();

        }

        /// <summary>
        /// 添加用户
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public ActionResult AddAdmin(Dto.Request.AdminRequestDto dto)
        {
            var result = _adminService.AddAdmin(dto);

            return Json(result);
        }
    }
}